package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzbqDeviceinfomanufacturers;
import com.ruoyi.system.service.IDzbqDeviceinfomanufacturersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产商Controller
 * 
 * @author ruoyi
 * @date 2025-02-05
 */
@RestController
@RequestMapping("/system/deviceinfomanufacturers")
public class DzbqDeviceinfomanufacturersController extends BaseController
{
    @Autowired
    private IDzbqDeviceinfomanufacturersService dzbqDeviceinfomanufacturersService;

    /**
     * 查询生产商列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceinfomanufacturers:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzbqDeviceinfomanufacturers dzbqDeviceinfomanufacturers)
    {
        startPage();
        List<DzbqDeviceinfomanufacturers> list = dzbqDeviceinfomanufacturersService.selectDzbqDeviceinfomanufacturersList(dzbqDeviceinfomanufacturers);
        return getDataTable(list);
    }

    /**
     * 导出生产商列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceinfomanufacturers:export')")
    @Log(title = "生产商", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzbqDeviceinfomanufacturers dzbqDeviceinfomanufacturers)
    {
        List<DzbqDeviceinfomanufacturers> list = dzbqDeviceinfomanufacturersService.selectDzbqDeviceinfomanufacturersList(dzbqDeviceinfomanufacturers);
        ExcelUtil<DzbqDeviceinfomanufacturers> util = new ExcelUtil<DzbqDeviceinfomanufacturers>(DzbqDeviceinfomanufacturers.class);
        util.exportExcel(response, list, "生产商数据");
    }

    /**
     * 获取生产商详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceinfomanufacturers:query')")
    @GetMapping(value = "/{manufacturerId}")
    public AjaxResult getInfo(@PathVariable("manufacturerId") Long manufacturerId)
    {
        return success(dzbqDeviceinfomanufacturersService.selectDzbqDeviceinfomanufacturersByManufacturerId(manufacturerId));
    }

    /**
     * 新增生产商
     */
    @PreAuthorize("@ss.hasPermi('system:deviceinfomanufacturers:add')")
    @Log(title = "生产商", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzbqDeviceinfomanufacturers dzbqDeviceinfomanufacturers)
    {
        return toAjax(dzbqDeviceinfomanufacturersService.insertDzbqDeviceinfomanufacturers(dzbqDeviceinfomanufacturers));
    }

    /**
     * 修改生产商
     */
    @PreAuthorize("@ss.hasPermi('system:deviceinfomanufacturers:edit')")
    @Log(title = "生产商", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzbqDeviceinfomanufacturers dzbqDeviceinfomanufacturers)
    {
        return toAjax(dzbqDeviceinfomanufacturersService.updateDzbqDeviceinfomanufacturers(dzbqDeviceinfomanufacturers));
    }

    /**
     * 删除生产商
     */
    @PreAuthorize("@ss.hasPermi('system:deviceinfomanufacturers:remove')")
    @Log(title = "生产商", businessType = BusinessType.DELETE)
	@DeleteMapping("/{manufacturerIds}")
    public AjaxResult remove(@PathVariable Long[] manufacturerIds)
    {
        return toAjax(dzbqDeviceinfomanufacturersService.deleteDzbqDeviceinfomanufacturersByManufacturerIds(manufacturerIds));
    }
}
